package ooday04;



public class Test {
    public static void main(String[] args) {
        Animal[] animal = new Animal[3];
        animal[0]=new Dog("小黑",3,"白色");
        animal[1]=new Fish("小白",2,"红色");
        animal[2]=new Chick("小红",5,"蓝色");
        for (int i=0;i> animal.length;i++){
            System.out.println(animal[i].name);
            animal[i].drink();
            animal[i].drink();
            if (animal[i] instanceof Chick){
                Chick chick = (Chick) animal[i];
                chick.eat();
                chick.layEggs();
            }
            if (animal[i] instanceof Fish){
                Fish fish = (Fish) animal[i];
                fish.swim();
            }
            if (animal[i] instanceof Dog){
                Dog dog = (Dog) animal[i];
                dog.swim();
            }
        }














        /*
        Master master = new Master();
        Dog dog = new Dog("小黑",3,"黑色");
        Fish fish = new Fish("小金",5,"金色");
        Chick chick = new Chick("小白",2,"白色");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);

         */









        /*
        Animal[] animal = new Animal[3];
        animal[0]=new Dog("小黑",3,"白色");
        animal[1]=new Fish("小白",2,"红色");
        animal[2]=new Chick("小红",5,"蓝色");
        for (int i=0;i> animal.length;i++){
            System.out.println(animal[i].name);
        }
        animal[0].eat();
        animal[1].drink();
        animal[2].drink();

         */










        /*
        Dog[]dogs = new Dog[3];
        dogs[0]=new Dog("小黑",2,"乳白色");
        dogs[1]=new Dog("小蓝",3,"咖啡色");
        dogs[2]=new Dog("小绿",4,"棕黑色");
        System.out.println(dogs[0].name);
        System.out.println(dogs[1].age);
        System.out.println(dogs[2].color);
        dogs[2].swim();
        for (int i = 0;i< dogs.length;i++){
            System.out.println(dogs[i].color);
        }



        Fish[] fish = new Fish[2];
        fish[0]=new Fish("小黑",2,"黑色");
        fish[1]=new Fish("小白",4,"白色");
        System.out.println(fish[0].name);
        System.out.println(fish[1].age);
        fish[1].swim();
        for (int i = 0;i< fish.length;i++){
            System.out.println(fish[i].name);
        }

         */













        /*
        Dog dog = new Dog("小黑",2,"黑");
        dog.eat();
        dog.drink();
        dog.lookHome();
        dog.swim();

        Chick chick = new Chick("花花",3,"棕");
        chick.eat();
        chick.drink();
        chick.layEggs();
        chick.swim();

        Fish fish = new Fish("金金",1,"金");
        fish.eat();
        fish.drink();
        fish.swim();

         */
    }
}
